<template>
  <div>
    <el-drawer
      ref="drawer"
      custom-class="wxkj-drawer"
      :title="drawerTitle"
      :destroy-on-close="true"
      :visible.sync="drawerShow"
      size="500"
      @close="drawerClose"
    >
      <div class="drawer-content">
        <el-form
          ref="CurriculumVitaeEditDrawerform"
          :model="form"
          :rules="formRules"
          label-width="120px"
        >
          <div class="wxkj-icon-title mb30">
            <span class="icon" />
            <span>职位基本信息</span>
          </div>
          <el-form-item label="所属公司：" required prop="companyId">
            <el-select
              v-model="form.companyId"
              filterable
              clearable
              placeholder="请选择"
              style="width: 100%"
              @change="listBatch"
            >
              <el-option
                v-for="item in companyList"
                :key="item.id"
                :label="item.enName"
                :value="item.id"
              />
            </el-select>
          </el-form-item>
          <el-form-item
            v-if="form.bsType == 0"
            label="职位批次："
            required
            prop="bsId"
          >
            <el-col :span="12">
              <el-select
                v-model="form.bsId"
                placeholder="请选择"
                style="width: 100%"
                clearable
                @change="oneBatchInfo(form.bsId)"
              >
                <el-option
                  v-for="item in batchData"
                  :key="item.id"
                  :label="item.name"
                  :value="item.id"
                />
              </el-select>
            </el-col>
            <el-col :span="12">
              <el-popover
                v-model="addvisible"
                class="ml20"
                width="400"
                trigger="manual"
              >
                <div>
                  <h3>新增</h3>
                  <el-input
                    v-model="addbatch.name"
                    placeholder="请输入批次名称"
                  />
                  <el-checkbox
                    v-model="addbatch.repeatFlag"
                    class="mt10"
                  >本批次同一个求职者可以同时投多个岗位</el-checkbox>
                </div>
                <el-button
                  type="primary"
                  class="fr mt10"
                  size="mini"
                  @click="submitBatch(0)"
                >保存</el-button>
                <span
                  slot="reference"
                  class="link-type"
                  @click="addBatch"
                >新增批次</span>
              </el-popover>
              <el-popover
                v-if="form.bsId"
                v-model="editvisible"
                class="ml10"
                width="400"
                trigger="manual"
              >
                <div>
                  <h3>编辑</h3>
                  <el-input
                    v-model="batch.name"
                    placeholder="请输入批次名称"
                  />
                  <el-checkbox
                    v-model="batch.repeatFlag"
                    class="mt10"
                  >本批次同一个求职者可以同时投多个岗位</el-checkbox>
                </div>
                <el-button
                  type="primary"
                  class="fr mt10"
                  size="mini"
                  @click="submitBatch(1)"
                >保存</el-button>
                <span
                  slot="reference"
                  class="link-type"
                  @click="editBatch"
                >编辑</span>
              </el-popover>

              <!-- <el-popover
                                class="ml10"
                                width="300"
                                trigger="manual"
                                >
                                    <span slot="reference" class="ml10 link-type" @click="delBatch">删除</span>
                                </el-popover> -->

              <el-popconfirm
                v-if="form.bsId"
                class="ml10"
                confirm-button-text="确定"
                cancel-button-text="关闭"
                icon="el-icon-info"
                icon-color="red"
                title="确定要删除此批次信息吗？"
                @onConfirm="delBatch"
              >
                <span slot="reference" class="link-type">删除</span>
              </el-popconfirm>
            </el-col>
          </el-form-item>

          <el-form-item label="招聘类型：" required prop="recruitType">
            <el-select
              v-model="form.recruitType"
              placeholder="请选择"
              style="width: 100%"
              clearable
            >
              <el-option
                v-for="item in recruitType"
                :key="item.value"
                :label="item.label"
                :value="item.value"
              />
            </el-select>
          </el-form-item>

          <el-form-item label="职位性质：" required prop="jobNature">
            <el-radio-group
              v-if="form.recruitType == '0'"
              v-model="form.jobNature"
            >
              <el-radio
                v-for="item in jobNature0"
                :key="item.value"
                :label="item.value"
              >{{ item.label }}</el-radio>
            </el-radio-group>

            <el-radio-group
              v-if="form.recruitType == '1'"
              v-model="form.jobNature"
            >
              <el-radio
                v-for="item in jobNature1"
                :key="item.value"
                :label="item.value"
              >{{ item.label }}</el-radio>
            </el-radio-group>
          </el-form-item>
          <el-form-item label="职位名称：" required prop="jobName">
            <el-input
              v-model="form.jobName"
              placeholder="请输入职位名称"
            />
          </el-form-item>
          <el-form-item label="职位类别：" required prop="jobTypeId">
            <el-cascader
              v-if="positionData.length > 0"
              v-model="form.jobTypeId"
              style="width: 100%"
              :show-all-levels="false"
              :options="positionData"

              filterable
            />
          </el-form-item>

          <el-form-item label="招聘行业：" required prop="jobIndustryId">
            <el-cascader
              v-if="tradeData.length > 0"
              v-model="form.jobIndustryId"
              style="width: 100%"
              :show-all-levels="false"
              :options="tradeData"

              filterable
            />
          </el-form-item>
          <el-form-item label="性别：">
            <el-radio-group v-model="form.jobSex">
              <el-radio label="0">不限</el-radio>
              <el-radio
                v-for="item in sex"
                :key="item.value"
                :label="item.value"
              >{{ item.label }}</el-radio>
            </el-radio-group>
          </el-form-item>
          <el-form-item label="年龄：">
            <el-select
              v-model="form.jobMaxAge"
              placeholder="请选择"
              style="width: 100%"
              clearable
            >
              <el-option
                v-for="item in age"
                :key="item.value"
                :label="item.label"
                :value="item.value"
              />
            </el-select>
          </el-form-item>
          <el-form-item label="语言：">
            <el-col :span="24">
              <el-input
                v-if="form.languageOr"
                v-model="form.language"
                placeholder="请输入语言"
              />
              <el-select
                v-else
                v-model="form.language"
                placeholder="请选择"
                style="width: 100%"
                clearable
              >
                <el-option
                  v-for="item in language"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value"
                />
              </el-select>
            </el-col>
            <!-- <el-col :span="4" class="pl20">
              <el-checkbox v-model="form.languageOr">其他</el-checkbox>
            </el-col> -->
          </el-form-item>
          <el-form-item label="招聘人数：" required prop="needCount">
            <el-input
              v-model.number="form.needCount"
              style="width: 100px"
              placeholder="请输入"
            />
            <span class="pl20">人</span>
          </el-form-item>
          <el-form-item label="学历：" required prop="eduLevel">
            <el-col :span="18" class="mr20">
              <el-col :span="11" class="mr5">
                <el-select
                  v-model="form.eduLevel"
                  placeholder="请选择"
                  style="width: 100%"
                  clearable
                >
                  <el-option
                    v-for="item in eduLevels"
                    :key="item.value"
                    :label="item.label"
                    :value="item.value"
                  />
                </el-select>
              </el-col>
              <el-col v-if="form.eduLevel > 3" :span="11" class="ml5">
                <el-select
                  v-model="form.schoolLevel"
                  placeholder="院校性质"
                  style="width: 100%"
                  clearable
                >
                  <el-option
                    v-for="item in schoolLevel"
                    :key="item.value"
                    :label="item.label"
                    :value="item.value"
                  />
                </el-select>
              </el-col>
            </el-col>
            <el-col v-if="form.eduLevel > 2" :span="4">
              <el-checkbox v-model="form.recruitmentFlag">统招</el-checkbox>
            </el-col>
          </el-form-item>
          <!-- <el-form-item label="职称要求：">
            <el-select
              v-model="form.jobRequire"
              placeholder="请选择"
              style="width: 100%"
			  clearable
            >
              <el-option
                v-for="item in jobRequire"
                :key="item.value"
                :label="item.label"
                :value="item.value"
              >
              </el-option>
            </el-select>
          </el-form-item> -->
          <el-form-item
            v-if="form.recruitType == 0"
            label="经验："
            required
            prop="experience"
          >
            <el-select
              v-model="form.experience"
              placeholder="请选择"
              style="width: 100%"
              clearable
            >
              <el-option
                v-for="item in experience"
                :key="item.value"
                :label="item.label"
                :value="item.value"
              />
            </el-select>
          </el-form-item>
          <el-form-item label="专业要求：">
            <!-- <el-select v-model="form.subject" placeholder="请选择" style="width: 100%;">
                        </el-select> -->
            <el-select
              v-model="form.subject"
              style="width: 100%"
              multiple
              filterable
              clearable
              remote
              reserve-keyword
              placeholder="请输入关键词"
              :remote-method="subjectPemoteMethod"
              :loading="subjectOptionsLoading"
            >
              <el-option
                v-for="item in subjectOptions"
                :key="item.id"
                :label="item.title"
                :value="item.id"
              />
            </el-select>
          </el-form-item>
          <el-form-item label="月薪范围：" required prop="minMoney">
            <el-col :span="6">
              <el-input
                v-model.number="form.minMoney"
                placeholder="输入金额"
                :disabled="form.salaryDisabled"
              />
            </el-col>
            <el-col class="text-center" :span="2">-</el-col>
            <el-col :span="6">
              <el-input
                v-model.number="form.maxMoney"
                placeholder="输入金额"
                :disabled="form.salaryDisabled"
              />
            </el-col>
            <el-col :span="6" :offset="2">
              <el-checkbox v-model="form.discuss" @change="toggleDiscuss">薪资面议</el-checkbox>
            </el-col>
          </el-form-item>
          <el-form-item label="过滤简历：">
            <el-col :span="12">
              <el-checkbox
                v-model="form.filterFlag"
                @change="filterCheckbox"
              >过滤不匹配的简历</el-checkbox>
            </el-col>
            <el-col :span="12" class="link-type">
              <span
                v-if="form.filterFlag"
                @click="filterDialogShow"
              >查看已设置的条件</span>
            </el-col>
            <div class="ps">
              注：勾选后，不满足您对工作经验、学历、语言等更多要求设置的简历，将被放入过滤简历中。
            </div>
          </el-form-item>
          <div class="wxkj-icon-title mb30">
            <span class="icon" />
            <span>职位详情</span>
          </div>
          <el-form-item label="岗位职责：" required prop="jobDuty">
            <el-input
              v-model="form.jobDuty"
              type="textarea"
              placeholder="请输入您的岗位职责要求"
            />
          </el-form-item>
          <el-form-item label="招聘要求：" required prop="jobClaim">
            <el-input
              v-model="form.jobClaim"
              type="textarea"
              placeholder="请输入您的岗位职责要求"
            />
          </el-form-item>
          <el-form-item label="工作地址：" required prop="areaData">
            <el-cascader
              v-if="areaData.length > 0"
              :key="cascaderKey"
              ref="cascader"
              v-model="form.areaData"
              style="width: 100%"
              :filterable="true"
              :options="areaData"
              @change="areaDataChange"
            />
          </el-form-item>
          <!-- 20240416 fangsong   因高德地图API收费，去掉所有关于地图的东西  -->
          <!--          <el-form-item label="详细地址：" required prop="jobArea">
            &lt;!&ndash; <div @click="graspLongLat" class="link-type">
                            <el-input placeholder="请选择详细地址" suffix-icon="" readonly="" v-model="form.jobArea"> </el-input>
                        </div> &ndash;&gt;
            <el-col :span="18">
              <el-input v-model="form.jobArea" placeholder="请输入详细地址" />
            </el-col>
            <el-col :span="6" class="pl20">
              <el-button
                icon="el-icon-location"
                @click="graspLongLat"
              />
            </el-col>
          </el-form-item>-->
          <el-form-item label="详细地址：" required prop="jobArea">
            <el-input v-model="form.jobArea" placeholder="请输入详细地址" />
          </el-form-item>
          <div class="drawer-form-buttom-group">
            <el-button type="primary" :loading="loading" @click="submitForm">保存</el-button>
            <el-button @click="close">取消</el-button>
          </div>
        </el-form>
      </div>
    </el-drawer>
    <!--    <map-dialog ref="mapDialog" @returnInfo="getMapInfo" />-->
    <filter-dialog ref="filterDialog" @result="getFilterId" @noFilter="noFilter" />
  </div>
</template>

<script>
// import mapDialog from './components/mapDialog'
import filterDialog from './components/filterDialog'
import { companyList } from '@/api/vip-company'
import { baseSo } from '@/api/common'
import { mapState } from 'vuex'
import store from '@/store'
import {
  add,
  edit,
  addBatch,
  delBatch,
  editBatch,
  listBatch,
  oneBatch
} from '@/api/position'
export default {
  components: { /* mapDialog, */filterDialog },
  props: {
    bsType: {
      // 批次/专场标识 0 批次 1 专场
      type: Number,
      default: 0
    },
    bsId: {
      // 批次/专场 id
      type: String,
      default: ''
    }
  },
  data() {
    var validateMoneyScope = (rule, value, callback) => {
      if (this.form.salaryDisabled) {
        callback()
      } else if (!parseInt(value) || !parseInt(this.form.maxMoney)) {
        callback(new Error('请填写完整月薪范围'))
      } else {
        if (parseInt(value) > parseInt(this.form.maxMoney)) {
          callback(new Error('上限月薪不能小于最低月薪'))
        } else if (parseInt(value * 2) < parseInt(this.form.maxMoney)) {
          callback(new Error('月薪范围不可大于2倍'))
        }
      }
      callback()
    }
    var validateEduLevel = (rule, value, callback) => {
      if (value === '') {
        callback(new Error('请选择学历'))
      } else {
        if (value > 3 && !this.form.schoolLevel) {
          callback(new Error('请选择院校性质'))
        }
      }
      callback()
    }
    /* var validateLatLong = (rule, value, callback) => {
      if (!this.form.jobLongitude) {
        callback(new Error('请点击选择经纬度'))
      }
      callback()
    }*/
    return {
      loading: false,
      addvisible: false,
      editvisible: false,
      batchData: [], // 批次列表
      addbatch: {
        name: '',
        repeatFlag: false
      },
      batch: {
        name: '',
        repeatFlag: false
      },
      mapInfoCity: {
        label: '',
        center: ''
      }, // 默认地图搜索城市
      subjectOptions: [],
      subjectOptionsLoading: false,
      formBatch: {},
      formRulesBatch: {},
      form: {
        sysFrom: 2,
        companyId: '',
        bsId: '',
        jobMaxAge: '', // 上行年龄
        recruitType: '',
        minMoney: '',
        maxMoney: '',
        discuss: false,
        salaryDisabled: false,
        language: '',
        eduLevel: '',
        schoolLevel: '',
        jobIndustryId: [],
        needCount: '',
        jobArea: '',
        jobSex: '0',
        jobNature: '',
        jobName: '',
        jobMinAge: '0',
        languageOr: '',
        jobRequire: '',
        experience: '',
        subject: [], // 专业要求
        jobDuty: '',
        jobClaim: '',
        areaData: [],
        jobLatitude: '',
        jobLongitude: '',
        jobTypeId: [],
        recruitmentFlag: false,
        recruitmentState: 0,
        filterFlag: false,
        filterId: ''
      },
      drawerTitle: '新增专场',
      drawerShow: false,
      recruitmentType: '', // 招聘类型
      companyList: [], // 企业名称列表
      areaData: [],
      cascaderKey: '1',
      positionData: [], // 招聘类型数据树
      tradeData: [],
      formRules: {
        bsId: [{ required: true, message: '请选择发布批次' }],
        companyId: [{ required: true, message: '请选择所属公司' }],
        recruitType: [{ required: true, message: '请选择招聘类型' }],
        jobNature: [{ required: true, message: '请选择职位性质' }],
        jobName: [{ required: true, message: '请输入职位名称' }],
        jobTypeId: [{ required: true, message: '请选择招聘类别' }],
        jobIndustryId: [{ required: true, message: '请选择招聘行业' }],
        needCount: [{ type: 'number', message: '请输入招聘人数' }],
        eduLevel: [{ validator: validateEduLevel }],
        experience: [{ required: true, message: '请选择工作经验' }],
        minMoney: [{ validator: validateMoneyScope }],
        jobDuty: [{ required: true, message: '请填写岗位职责' }],
        jobClaim: [{ required: true, message: '请填写招聘要求' }],
        areaData: [{ required: true, message: '请选择工作地址' }],
        jobArea: [
          { required: true, message: '请输入详细地址' }
          /* { validator: validateLatLong }*/
        ]
      } // 表单校验
    }
  },
  // 方法
  methods: {
    noFilter() {
      this.form.filterFlag = false
    },
    filterCheckbox(e) {
      if (e) {
        this.filterDialogShow()
      }
    },
    toggleDiscuss(val) {
      this.form.salaryDisabled = val
      if (val) {
        // 薪资面议，将最小最大薪资调整为0
        this.form.minMoney = '0'
        this.form.maxMoney = '0'
      } else {
        this.form.minMoney = ''
        this.form.maxMoney = ''
      }
    },
    close() {
      this.$refs.drawer.closeDrawer()
    },
    getFilterId(id) {
      this.form.filterId = id
    },
    addBatch() {
      this.addvisible = !this.addvisible
      this.editvisible = false
    },
    editBatch() {
      this.editvisible = !this.editvisible
      this.addvisible = false
    },
    // 删除批次
    delBatch() {
      delBatch({
        id: this.batch.id
      }).then((res) => {
        this.form.bsId = ''
        this.batch = {
          id: '',
          name: '',
          repeatFlag: false
        }
        this.listBatch()
      })
    },
    submitBatch(type) {
      const companyId = this.form.companyId
      if (!companyId) {
        this.$message.error('请先选择所属公司')
      } else {
        if (type == 0) {
          // 新增
          const batch = this.addbatch
          if (!batch.name) {
            this.$message.error('请输入批次名称')
          } else {
            batch.companyId = companyId
            addBatch(batch).then((res) => {
              this.addbatch = {
                name: '',
                repeatFlag: false
              }
              this.addvisible = false
              this.listBatch()
            })
          }
        } else {
          const batch = this.batch
          if (!batch.name) {
            this.$message.error('请输入批次名称')
          } else if (!batch.id) {
            this.$message.error('请选择要修改的批次信息')
          } else {
            editBatch(batch).then((res) => {
              this.editvisible = false
              this.listBatch()
            })
          }
        }
      }
    },
    // 查询批次列表
    listBatch() {
      const companyId = this.form.companyId
      listBatch({ companyId: companyId, pageNo: 1, pageSize: 1000 }).then(
        (res) => {
          this.batchData = res.result.records
        }
      )
    },
    // 获取单个批次详情
    oneBatchInfo(id) {
      if (id) {
        oneBatch({ id: id }).then((res) => {
          const data = res.result
          this.batch = {
            id: data.id,
            name: data.name,
            repeatFlag: data.repeatFlag
          }
        })
      }
    },
    // 专业要求异步搜索
    subjectPemoteMethod(query) {
      if (query) {
        this.subjectOptionsLoading = true
        baseSo({
          'title.keywords': query,
          type: 'speciality',
          pageNo: 1,
          pageSize: 30
        }).then((res) => {
          this.subjectOptions = res.result// .content;
          this.subjectOptionsLoading = false
        })
      } else {
        this.subjectOptions = []
      }
    },
    // 显示
    show(title, d, bsId) {
      this.$nextTick(() => {
        if (this.$refs.CurriculumVitaeEditDrawerform) {
          this.$refs.CurriculumVitaeEditDrawerform.clearValidate()
        }
      })
      this.drawerTitle = title
      if (bsId) {
        this.form.bsId = bsId
        this.form.bsType = 1
      } else {
        this.form.bsType = 0
      }
      if (d) {
        const data = JSON.parse(JSON.stringify(d))
        data.recruitType = data.recruitType != null ? data.recruitType.toString() : ''
        data.jobSex = data.jobSex != null ? data.jobSex.toString() : ''
        data.jobMinAge = data.jobMinAge != null ? data.jobMinAge.toString() : ''
        data.jobMaxAge = data.jobMaxAge != null ? data.jobMaxAge.toString() : ''
        data.eduLevel = data.eduLevel != null ? data.eduLevel.toString() : ''
        data.schoolLevel = data.schoolLevel != null ? data.schoolLevel.toString() : ''
        data.jobRequire = data.jobRequire != null ? data.jobRequire.toString() : ''
        data.recruitmentFlag = data.recruitmentFlag == 0
        if (data.jobTypeId) {
          data.jobTypeId = data.jobTypeId.split(',')
        }
        if (data.bsType == 0) {
          this.oneBatchInfo(data.bsId)
        }
        data.jobIndustryId = data.jobIndustryId.split(',')
        if (data.subject) {
          data.subject = data.subject.split(',')
          const subjectText = data.subject_dictText.split(',')
          subjectText.forEach((item, index) => {
            this.subjectOptions.push({
              id: data.subject[index],
              title: item
            })
          })
        }
        data.experience = data.minExperience + ',' + data.maxExperience
        data.areaData = [data.jobProvince, data.jobCity, data.jobCounty]
        this.mapInfoCity = {
          label: data.jobCity_dictText,
          center: data.jobLongitude + data.jobLatitude
        }
        this.$nextTick(() => {
          this.form = data
          this.listBatch()
          this.form.salaryDisabled = data.minMoney === 0 && data.maxMoney === 0
          this.form.discuss = data.minMoney === 0 && data.maxMoney === 0
        })
      }
      this.drawerShow = true
    },
    /* graspLongLat() {
      this.$refs.CurriculumVitaeEditDrawerform.validateField(['areaData'], (valid) => {
        if (valid) return
        console.log(this.mapInfoCity)
        this.$refs.mapDialog.show(this.mapInfoCity)
      })
    },*/
    // 获取地图信息
    /* getMapInfo(arr, address) {
      this.form.jobLongitude = arr[0]
      this.form.jobLatitude = arr[1]
      if (address) {
        this.form.jobArea = address
      }
      this.$refs.CurriculumVitaeEditDrawerform.clearValidate('jobArea')
    },*/
    filterDialogShow() {
      this.$refs.filterDialog.show(this.form.filterId)
    },
    areaDataChange(e) {
      this.$nextTick(() => {
        const data = this.$refs.cascader.getCheckedNodes()
        this.mapInfoCity = {
          label: data[0].parent.data.label,
          center: data[0].parent.data.center
        }
        this.cascaderKey = new Date().getTime()
      })
    },
    // 关闭弹窗
    drawerClose(e) {
      this.mapInfoCity = {
        label: '',
        center: ''
      }
      this.loading = false
      this.subjectOptions = []
      this.editvisible = false
      this.addvisible = false
      // this.$refs.CurriculumVitaeEditDrawerform.resetFields();
      this.form = this.$options.data().form
      this.drawerShow = false
      this.$emit('refresh')
    },
    // 提交
    submitForm() {
      this.$refs.CurriculumVitaeEditDrawerform.validate((valid) => {
        if (valid) {
          this.loading = true
          const form = JSON.parse(JSON.stringify(this.form))
          form.jobTypeId = form.jobTypeId.join(',') // 职位类别
          form.jobIndustryId = form.jobIndustryId.join(',')
          const area = form.areaData
          form.jobProvince = area[0]
          form.jobCity = area[1]
          form.jobCounty = area[2]
          form.areaData = '' // 地址赋值
          form.jobMaxAge = form.jobMaxAge ? form.jobMaxAge : '0'
          if (form.experience) {
            const experience = form.experience.split(',')
            form.minExperience = experience[0]
            form.maxExperience = experience[1]
          } else {
            form.minExperience = 0
            form.maxExperience = 999
          }
          form.recruitmentFlag = form.recruitmentFlag ? 0 : 1
          if (form.subject.length > 0) {
            form.subject = form.subject.join(',')
          } else {
            form.subject = ''
          }
          if (form.id) {
            form.createTime = ''
            form.updateTime = ''
            form.closeTime = ''
            edit(form).then((res) => {
              this.$message({
                message: '修改成功',
                type: 'success'
              })
              this.close()
            }).catch(err => {
              this.loading = false
            })
          } else {
            add(form).then((res) => {
              this.$message({
                message: '添加成功',
                type: 'success'
              })
              this.close()
            }).catch(err => {
              this.loading = false
            })
          }
        }
      })
    }
  },
  computed: {
    ...mapState({
      recruitType: (state) => state.app.recruitType, // 招聘类型
      sex: (state) => state.app.sex, // 招聘类型
      age: (state) => state.app.age, // 性别
      schoolLevel: (state) => state.app.schoolLevel, // 校园性质
      jobRequire: (state) => state.app.jobRequire, // 职称要求
      experience: (state) => state.app.experience, // 经验限制
      jobNature0: (state) => state.app.jobNature0, // 经验限制
      jobNature1: (state) => state.app.jobNature1,
      eduLevels: (state) => state.app.eduLevels, // 经验限制
      language: (state) => state.app.language // 经验限制
    })
  },
  // 生命周期 - 创建完成（可以访问当前this实例）
  async created() {
    companyList({ state: 0, pageSize: -1 }).then((res) => {
      this.companyList = res.result.records
    })
    if (this.$store.state.app.areaData.length === 0) {
      const res = await store.dispatch('app/getArea', 'area')
      this.areaData = res.result
    } else {
      this.areaData = this.$store.state.app.areaData
    }

    if (this.$store.state.app.positionData.length === 0) {
      const res = await store.dispatch('app/getPosition', 'position')
      this.positionData = res.result
    } else {
      this.positionData = this.$store.state.app.positionData
    }

    // 行业数据
    if (this.$store.state.app.tradeData.length === 0) {
      const res = await store.dispatch('app/getTrade', 'industry')
      this.tradeData = res.result
    } else {
      this.tradeData = this.$store.state.app.tradeData
    }
  },
  // 生命周期 - 挂载完成（可以访问DOM元素）
  mounted() {},
  // 销毁
  destroyed() {}
}
</script>
<style lang="scss" scoped>
.wxkj-drawer {
  .drawer-content {
    .ps {
      font-size: 14px;
      font-weight: 400;
      line-height: 19px;
      color: #999999;
      margin-top: 15px;
      display: inline-block;
    }
  }
}
</style>
